<!--
	作者：2575202388@qq.com
	时间：2018-10-14
	描述：Checkbox 子框
-->
<template>
	<CheckboxGroup v-model="tempdata.checkeddata" @on-change="checkChange">
		<slot name="list"></slot>
	</CheckboxGroup>
</template>

<script>
	export default {
		name: "ChildrenCheckbox",
		props: {
			cData: {
				type: Object,
				default: function() {
					return this.checkData();
				}
			}
		},
		data() {
			return {
				tempdata: this.checkData()
			}
		},
		methods: {
			checkChange(data) {
				if(data.length == this.tempdata.datas.length) {
					this.tempdata.indeterminate = false;
					this.tempdata.checkAll = true;
				} else if(data.length > 0) {
					this.tempdata.indeterminate = true;
					this.tempdata.checkAll = false;
				} else {
					this.tempdata.indeterminate = false;
					this.tempdata.checkAll = false;
				}
			},
			init() {
				this.tempdata = this.cData;
			}
		},
		updated() {
			this.init();
		},
		mounted() {
			this.init();
		}
	}
</script>

<style scoped="scoped">

</style>